<%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="com.pengtu.gsj.entity.zxgc.ProjectData"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>专项工程--${fns:getConfig('productName')}</title>
<link href="${ctx}/styles/tag/jq22.css" type="text/css" rel="stylesheet" />
<link href="${ctx}/static/bootstrap/2.3.1/css/docs.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="${ctx}/styles/gsjcss/common.css">
<style>
.control-group{
	float:left;
}
select{
	width:220px;
}
 html, body { height: 100%; }
 .fileTable{
	 width:85%;
	 text-align:center;
	 margin-top:5px;
	 margin:auto;
	 margin-top:10px;
 }
 .fileTable td, .fileTable th{
 	padding:10px;
 	coloe:black;
 }
  .control-group{
 margin-top:0px !important;
 }
 .controls input{
 	width:60px;
 }
 legend{
 	clear:both;
 	width:8%;
 	border-bottom:none;
 	margin-bottom:0px;
 }
 hr{
 	margin:0 0 !important;
 	clear:both;
 }
 .controls{
 	margin-left:130px !important;
 }
 .control-label{
 	width:120px !important;
 }
  .tabbox{
 	width:90%;
 	margin:auto;
 }
 .tabbox th,.tabbox td,#dataStatic td{
 	padding:5px;
 }
 .tabbox .content{
 	height:300px;
 }
</style>
</head>
<body >
<ul class="nav nav-tabs" style="margin: 0 4px; margin-bottom: 4px;">
		<li >
			<a href="${ctx}/specialProject/listInfo.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}">
				<i class="icon icon-list"></i>&nbsp;<span>专项工程列表</span>
			</a>
		</li>
		<sec:authorize ifAnyGranted="ROLE_sys_user_edit"></sec:authorize>
		<li class="active">
			<a href="${ctx}/specialProject/view.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}&id="+${id}>
				<i class="icon icon-edit"></i>&nbsp;<span>编辑</span>
			</a>
	 	</li>
	</ul>
    			<legend>基本信息</legend>
    			<hr> 
    			<table style="width:90%;margin:auto;text-align:center" border="0">
					<tbody>
						<tr style="height:30px;">
							<td style="width:10%">项目名称：</td>
							<td style="width:20%;text-align:left;">${specialProject.projectName}</td>
							<td style="width:10%">截止时间：</td>
							<td style="width:20%;text-align:left;">${specialProject.endTime}</td>
							<td style="width:10%">提前预警时间：</td>
							<td style="width:10%;text-align:left;">${specialProject.advanceTime} &nbsp;小时</td>
							<td style="width:10%"></td>
							<td style="width:10%;text-align:left;"></td>
						</tr>
						<tr style="height:30px;">
							<td style="width:10%">专项数据：</td>
							<td colspan="7" style="text-align:left">
								<div class="plus-tag tagbtn clearfix" id="myTags" style="margin-top:20px;">
									<c:forEach items="${specialProject.tabList}" var="tab">
											<a value="-1" title="${tab}" href="javascript:void(0);"><span>${tab}</span></a>
										</c:forEach>		
								</div>
							</td>
						</tr>
						<tr style="height:30px;">
							<td style="width:10%">项目描述：</td>
							<td colspan="7" style="text-align:left">
							${specialProject.projectDesc}
							</td>
						</tr>
						<tr style="height:30px;">
							<td style="width:10%">备注：</td>
							<td colspan="7" style="text-align:left">
							${specialProject.remark}
							</td>
						</tr>
					</tbody>
				</table>
<!-- 			<legend>相关附件</legend> -->
	   <form id="inputForm" action="${ctx}/specialProject/saveData.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&LId=${fns:encodeParamUrl(LId)}"
		method="post"  class="form-horizontal m">
 		<input type="hidden" name="token" value="${token}">
		<input type="hidden" name="projId" id="projId" value="${specialProject.id}" />
		<input type="hidden" name="orgId" id="orgId" value="${orgId}" />
		<input type="hidden" name="dataId" id="dataId" value="${projectData.id}" />
		<input type="hidden" name="dataJson" id="dataJson" value='${projectData.dataJson}' />
		<input type="hidden" name="dataContent" id="dataContent" value='' />
		<fieldset id="field">
    			<legend>专项数据</legend>
    			<hr> 
    			<c:forEach items="${list}" var="tab" varStatus="status">
    				<c:if test="${status.index%3==0}">
    					<div class="control-group" style="clear:both">
    				</c:if>
    				<c:if test="${status.index%3!=0}">
    					<div class="control-group">
    				</c:if>
						<label class=" control-label">${tab}<font style="color:red;">*</font>:</label>
						<div class="controls">
						  <input class="required" id="data${status.index}" name="data${status.index}"
								type="text" value="">
						</div>
					</div>
    			</c:forEach>
    			<legend style="float:left;">相关附件</legend>
    			<button class="btn btn-success " type="button" style="float:left" id="button_${id}${tableField}" 
						onclick='uploadAttachmentFiles("${orgId}","T_YH_SPECIALPROJECT","${specialProject.id}","id","专项工程")' data-toggle="dropdown">
							工程附件<i class='icon-arrow-up'></i>
						</button>
    			<hr> 
    			<div class="tabbox">
					<div class="tab" id="orgTab"></div>
					<div class="content" id="fileContent">
						<ul>
			
						</ul>
					</div>
				</div>
		</fieldset>
      <div class="form-actions" style="text-align:center;padding-left:0px;">
		<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" />
			&nbsp; &nbsp;&nbsp;&nbsp;
		<input id="btnCancel" class="btn" type="button" value="返 回" onclick="JavaScript:history.go(-1);" />
	 </div>
	</form>
	<script type="text/javascript" src="${ctx}/js/jqTag.js"></script>
	<script type="text/javascript" src="${ctxStatic}/js/zxgc/specialProject.js"></script>
	<script>
	
	function uploadAttachmentFiles(tableId,tableName,partId,tableField,labelName){
		top.$.jBox("iframe:"+appConfig.contPath+"/attachment/uploads.do?tableId="+tableId+"&tableName="+tableName+"&partId="+partId+"&tableField="+tableField, 
 			{
 			 title: labelName+"文件上传",
 			 width: 800,
 		     height: 500,
 		     showClose:true,
 		     persistent:true,
 			 buttons:{"关闭":"ok",}, 
 			 closed:function(v, h, f){
 				 //更新文件
 				updateFile();
 			}, 
 			loaded:function(h){
 				$(".jbox-content", top.document).css("overflow-y","hidden");
 			}
 		});
 	}
	
	$(document).ready(function(){
		//将专项数据填充到表单中
		var dataJson = $.parseJSON($('#dataJson').val());
		loadDataToDiv('field',dataJson);
		$("#inputForm").validate({
			rules: {
				data0:{
					number:true
				},
				data1:{
					number:true
				},
				data2:{
					number:true
				},
				data3:{
					number:true
				},
				data4:{
					number:true
				},
				data5:{
					number:true
				},
				data6:{
					number:true
				},
				data7:{
					number:true
				},
				data8:{
					number:true
				},
				data9:{
					number:true
				}
			},
			messages: {
			},
			submitHandler:function(form){
				var dataJson = getJson('field');
				var dataContent = "";
				$('#dataJson').val(dataJson);
				$('#field input').each(function(){
					dataContent += $(this).val()+";";
				});
				dataContent = dataContent.substring(0,dataContent.length-1);
				$('#dataContent').val(dataContent);
				form.submit();
			},
			errorContainer: "#messageBox",
			errorPlacement: function(error, element) {
				$("#messageBox").text("输入有误，请先更正。");
				if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
					error.appendTo(element.parent().parent());
				} else {
					error.insertAfter(element);
				}
			}
		});
		
		//动态请求文件数据
		updateFile();
	});
	
	function updateFile(){
		var url = appConfig.contPath + "/specialProject/loadFiles.do?projectId="+$('#projId').val();
		 $.ajax({    
	         type:'post',        
	         url:url,    
	         cache:false,    
	         dataType:'json',    
	         success:function(data){  
	        	 loadFiles(data, true);
	        	 tabBox();
	         }    
	     });    
	}
	
	
	function getJson(divId){
		var term = {};
		$('#'+divId+' *').each(function(){
			if($(this).attr('name') != undefined){
				term[$(this).attr('name')] = $(this).val();
			}
		});
		var params = JSON.stringify(term);
		return params;
	}
	</script>
</body>
</html>
